package com.woniu.mapper;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.woniu.entity.Expense;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hyl
 * @since 2022-08-28
 */
public interface ExpenseMapper extends BaseMapper<Expense> {
    //查询全部
    @Select("select * from expense")
    List<Expense> getAll();
    //根据ID查询
    @Select("select * from expense where exp_id = #{expId}")
    Expense getByExpID(int expId);
    //添加类别
    @Insert("insert into expense(exp_category) values(#{expCategory})")
    void addExp(String expCategory);
    //修改类别
    @Update("update expense set exp_category = #{expCategory} where exp_id = #{expId}")
    void updateExp(Expense expense);
    //多条件查询
    @Select("select * from expense ${ew.customSqlSegment}")
    List<Expense> getByCondition(@Param(Constants.WRAPPER) Wrapper<Expense> wrapper);
}
